﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Xna.Framework;

namespace LevelEditor
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void xnaCanvas1_Click(object sender, EventArgs e)
        {

        }

        private Boolean mouseDown = false;
        private int mouseX = 0;
        private int mouseY = 0;

        private void xnaCanvas1_MouseDown(object sender, EventArgs e)
        {
            mouseX = Control.MousePosition.X;
            mouseY = Control.MousePosition.Y;
            mouseDown = true;
        }

        private void xnaCanvas1_MouseUp(object sender, EventArgs e)
        {
            mouseDown = false;
        }

        private void xnaCanvas1_MouseMove(object sender, MouseEventArgs e)
        {
            //System.Diagnostics.Debug.WriteLine(e.X + " " + e.Y);
            if (mouseDown)
            {
                int oldMouseX = mouseX;
                int oldMouseY = mouseY;

                mouseX = Control.MousePosition.X;
                mouseY = Control.MousePosition.Y;

                float distanceX = mouseX - oldMouseX;
                float distanceY = mouseY - oldMouseY;

                xnaCanvas1.yaw = xnaCanvas1.yaw + distanceX / 80;
                xnaCanvas1.pitch = xnaCanvas1.pitch + distanceY / 80;

                xnaCanvas1.mouseX = e.X;
                xnaCanvas1.mouseY = e.Y;

                xnaCanvas1.textbox = textBox1;

                xnaCanvas1.Invalidate();
            }

        }
    }
}
